<%--
  Created by IntelliJ IDEA.
  User: 61741
  Date: 2017/12/5
  Time: 23:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>资讯</title>
    <meta charset="utf-8">
    <jsp:include page="../common/portal-head.jsp"></jsp:include>
    <link rel="stylesheet" type="text/css" href="${ctx}/resources/portal/css/info.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/resources/portal/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/resources/portal/css/shopslider.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/resources/portal/css/page.css">
</head>
<body>
<div class="page-container">
    <jsp:include page="../portal/topmenu.jsp"></jsp:include>
    <jsp:include page="../portal/slider.jsp"></jsp:include>
    <div class="content-wrap">
        <div class="hot-info" id="topinfo">

        </div>
        <div class="all-info-wrap">
            <div class="title-nav" id="section-menu">
                <h1>行业资讯</h1>
                <ul>
                    <li><img src="${ctx}/resources/portal/img/info_nav_dirc.png">内衣、裤资讯</li>
                    <li><img src="${ctx}/resources/portal/img/info_nav_dirc.png">展销会资讯</li>
                    <li><img src="${ctx}/resources/portal/img/info_nav_dirc.png">辅料、配件资讯</li>
                    <li><img src="${ctx}/resources/portal/img/info_nav_dirc.png">其他资讯</li>
                </ul>
            </div>
            <div class="top-info-wrap" id="infopic">
                <%--<img class="top-info-pic" src="${ctx}/resources/portal/img/banner/info_top_01.jpg">--%>
                <%--<img class="top-info-pic" src="${ctx}/resources/portal/img/banner/info_top_02.jpg">--%>
                <%--<img class="top-info-pic" src="${ctx}/resources/portal/img/banner/info_top_03.jpg">--%>
            </div>
            <div class="info-list" id="infolist">
            </div>
            <div id="page" class="page_div"></div>
        </div>
    </div>
</div>
<jsp:include page="../portal/footer.jsp"></jsp:include>
<script id="slider-tml" type="text/html">
    <li><img src="\${url}"></li>
</script>
<script id="topinfo-tml" type="text/html">
    <div class="hot-info-item" onclick="javascript:window.location.href='${ctx}/articledetail/index/\${id}'">
        <img class="info-pic" src="\${portal_img}">
        <span class="hot-tip">热门</span>
        <div class="info-dsc-outline">
            <div class="info-dsc">
                <span class="seller-name"><img src="">\${user_nickname}</span>
                <hr>
                <span class="info-title">\${main_title}</span>
                <p>\${sub_title}</p>
            </div>
        </div>
    </div>
</script>
<script id="infopic-tml" type="text/html">
    <img class="top-info-pic" onclick="javascript:window.location.href='${ctx}/articledetail/index/\${id}'" src="\${portal_img}">
</script>

<script id="sectionmenu-tml" type="text/html">
    <li value="\${id}" onclick="changePage('\${id}')"><img src="${ctx}/resources/portal/img/info_nav_dirc.png">\${sectionName}</li>
</script>

<script id="infolist-tml" type="text/html">
    <div class="com-info-outline" onclick="javascript:window.location.href='${ctx}/articledetail/index/\${id}'">
        <div class="com-info-item">
        <img class="com-info-logo" src="\${portal_img}">
        <div class="com-info-dsc">
        <div class="dsc-title">
        <h2>\${main_title}</h2>
        <span>\${formatDate(create_time)}</span>
    </div>
    <p>\${sub_title}</p>
    <div class="info-phone-wrap">
        <span class="add-phone"><img src="${ctx}/resources/portal/img/info_add_01.png">\${user_nickname}</span>
        <span class="add-phone"><img src="${ctx}/resources/portal/img/info_add_02.png">热线电话:\${userContact}</span>
    </div>
    </div>
    </div>
    </div>
</script>
<script src="${ctx}/resources/portal/script/page.js"  type="text/javascript"></script>
<script type="text/javascript">
    var city="default";
    var scope="INFO";
    var sectionId=4;
    $(function () {
        loadSlider(city);
        loadAllSections();
        loadtopInfo();
        loadbannerInfo();
        loadAllInfo();
    })
    function changePage(section){
        sectionId=section;
        loadSlider(city);
        loadtopInfo();
        loadbannerInfo();
        loadAllInfo();
    }
    function loadSlider(city) {
        var data = {city: city,sectionId:sectionId};
        asyncAjax({
            url: ctx + "/portal/carousel/list/"+scope+"?" + $.param(data).replace(/(%5D|%5B)/g, ""),
            success: function (res) {
                if (res["result"] == "0") {
                    if (!isEmpty(res["data"])) {
                        $("#slider-ul").html("");
                        $("#slider-tml").tmpl(res["data"]).appendTo($("#slider-ul"));
                        // 修正轮播图插件图片宽度自适应问题

                        $(".slider-img").attr("style", "width:" + $(".slider-img-ul li").length * 100 + "% !important;");
                        $(".slider-img-ul>li>img").css({
                            width: $(".slider-wrap").width() + "px !important",
                            height: "auto !important"
                        });
                        $(".slider").xSlider({w: 1340});
                    }
                    else {
                        $("#newGood-table").html('<li><img src="${ctx}/resources/portal/img/banner/1-banner.jpg"></li>');
                    }
                }
                else {
                    bootbox.alert(res["msg"]);
                }
            }

        })
    }

    function loadAllSections() {
        var data = {status: 1};
        asyncAjax({
            url: ctx + "/forum/list?" + $.param(data).replace(/(%5D|%5B)/g, ""),
            beforesend:function (req) {
                $("#section-menu ul").html('<i class="fa fa-spin fa-spinner"></i>正在刷新数据...');
            },
            success: function (res) {
                $("#section-menu ul").html("");
                if (res["result"] == "0") {
                    if (!isEmpty(res["data"])) {
                        $("#sectionmenu-tml").tmpl(res["data"]).appendTo($("#section-menu ul"));
                    }
                }
                else {
                    bootbox.alert(res["msg"]);
                }
            }

        })

    }
    function loadAllInfo(pageNum) {
        var data = {pageNum:pageNum||1,pageSize:10,section_id:sectionId,type:1};
        asyncAjax({
            url: ctx + "/article/getSearchList?" + $.param(data).replace(/(%5D|%5B)/g, ""),
            beforesend:function (req) {
                $("#infolist").html('<i class="fa fa-spin fa-spinner"></i>正在刷新数据...');
            },
            success: function (res) {
                $("#infolist").html("");
                if (res["result"] == "0") {
                    if (!isEmpty(res["data"])) {
                        $("#infolist-tml").tmpl(res["data"]).appendTo($("#infolist"));
                        $("#page").paging({
                            pageNo:pageNum || 1,
                            totalPage:Math.ceil(res.total/10),
                            totalSize: res.total,
                            callback: function(num) {
                                loadAllInfo(num);
                            }
                        })
                    }
                }
                else {
                    bootbox.alert(res["msg"]);
                }
            }

        })

    }
    function loadtopInfo() {
        var data = {pageNum:1,pageSize:3,section_id:sectionId,type:1,ad_option:"LIST_TOP"};
        asyncAjax({
            url: ctx + "/article/getSearchList?" + $.param(data).replace(/(%5D|%5B)/g, ""),
            beforesend:function (req) {
                $("#infopic").html('<i class="fa fa-spin fa-spinner"></i>正在刷新数据...');
            },
            success: function (res) {
                $("#infopic").html("");
                if (res["result"] == "0") {
                    if (!isEmpty(res["data"])) {
                        $("#infopic-tml").tmpl(res["data"]).appendTo($("#infopic"));
                    }
                }
                else {
                    bootbox.alert(res["msg"]);
                }
            }

        })

    }
    function loadbannerInfo() {
        var data = {pageNum:1,pageSize:4,section_id:sectionId,type:1,ad_option:"BANNER"};
        asyncAjax({
            url: ctx + "/article/getSearchList?" + $.param(data).replace(/(%5D|%5B)/g, ""),
            beforesend:function (req) {
                $("#topinfo").html('<i class="fa fa-spin fa-spinner"></i>正在刷新数据...');
            },
            success: function (res) {
                $("#topinfo").html("");
                if (res["result"] == "0") {
                    if (!isEmpty(res["data"])) {
                        $("#topinfo-tml").tmpl(res["data"]).appendTo($("#topinfo"));
                    }
                }
                else {
                    bootbox.alert(res["msg"]);
                }
            }

        })

    }
    /*收藏*/
    function collect(collectid){
        var celflag=document.getElementById(collectid).alt;
        alert(celflag);

        if(celflag==0){

            document.getElementById(collectid).src="${ctx}/resources/portal/img/after_collect.png";
            document.getElementById(collectid).alt="1";
        }
        else{
            document.getElementById(collectid).src="${ctx}/resources/portal/img/before_collect.png";
            document.getElementById(collectid).alt="0";
        }

    }
    /*商品目录导航*/
    $(document).ready(function() {
        $('.inactive').click(function(){
            if($(this).siblings('ul').css('display')=='none'){
                $(this).parent('li').siblings('li').removeClass('inactives');
                $(this).addClass('inactives');
                $(this).siblings('ul').slideDown(100).children('li');
                if($(this).parents('li').siblings('li').children('ul').css('display')=='block'){
                    $(this).parents('li').siblings('li').children('ul').parent('li').children('a').removeClass('inactives');
                    $(this).parents('li').siblings('li').children('ul').slideUp(100);

                }
            }else{
                //控制自身变成+号
                $(this).removeClass('inactives');
                //控制自身菜单下子菜单隐藏
                $(this).siblings('ul').slideUp(100);
                //控制自身子菜单变成+号
                $(this).siblings('ul').children('li').children('ul').parent('li').children('a').addClass('inactives');
                //控制自身菜单下子菜单隐藏
                $(this).siblings('ul').children('li').children('ul').slideUp(100);

                //控制同级菜单只保持一个是展开的（-号显示）
                $(this).siblings('ul').children('li').children('a').removeClass('inactives');
            }
        })
    });
</script>
<script src="${ctx}/resources/portal/script/xSlider.js"  type="text/javascript"></script>
</body>
</html>
